package o;

import android.content.Context;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.application.pkgmanage.model.reserve.ReserveDbInfo;
import com.huawei.appgallery.foundation.card.gamereserve.bean.OrderAppCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import java.util.ArrayList;
import java.util.List;

public class efi {
    private static efi ˎ;
    private static final Object ˏ = new Object();

    public static efi ˎ() {
        efi o_efi;
        synchronized (ˏ) {
            if (ˎ == null) {
                ˎ = new efi();
            }
            o_efi = ˎ;
        }
        return o_efi;
    }

    public cia ˏ(Context context) {
        cia o_cia = new cia(context);
        ˏ(o_cia, ˏ(efg.ˋ().ॱ()), cib.ˏ("orderappcard"), 0);
        return o_cia;
    }

    public int ˊ() {
        if (!UserSession.getInstance().isLoginSuccessful()) {
            return 0;
        }
        List ॱ = efg.ˋ().ॱ();
        if (ॱ.isEmpty()) {
            return 0;
        }
        return ॱ.size();
    }

    public boolean ॱ(cia o_cia) {
        if (o_cia == null) {
            Logger.e("PersonalReservedManager", "refreshAllItems error, cardDataProvider is null");
            return false;
        }
        chz ॱ = o_cia.ॱ(0);
        if (ॱ == null) {
            return false;
        }
        List ˏ = ˏ(efg.ˋ().ॱ());
        ॱ.ˊ(ˏ);
        if (ˏ.isEmpty()) {
            return false;
        }
        return true;
    }

    private List<CardBean> ˏ(List<ReserveDbInfo> list) {
        List<CardBean> arrayList = new ArrayList();
        if (!(list == null || list.isEmpty())) {
            for (int i = 0; i < list.size(); i++) {
                ReserveDbInfo reserveDbInfo = (ReserveDbInfo) list.get(i);
                OrderAppCardBean orderAppCardBean = new OrderAppCardBean();
                orderAppCardBean.ॱ(reserveDbInfo.ˊ());
                orderAppCardBean.ˉ(reserveDbInfo.ॱ());
                orderAppCardBean.ʼॱ(reserveDbInfo.ʼ());
                orderAppCardBean.ˊᐝ(reserveDbInfo.ʻ());
                orderAppCardBean.ˈ(reserveDbInfo.ॱॱ());
                orderAppCardBean.ˏॱ(reserveDbInfo.ͺ());
                orderAppCardBean.ˋॱ(reserveDbInfo.ॱˎ());
                orderAppCardBean.ˋᐝ(reserveDbInfo.ᐝ());
                orderAppCardBean.ʾ(reserveDbInfo.ʻॱ());
                orderAppCardBean.ˋ(reserveDbInfo.ˎ());
                orderAppCardBean.ˏˎ(reserveDbInfo.ˋ());
                orderAppCardBean.ॱ(reserveDbInfo.ॱᐝ());
                orderAppCardBean.ˏॱ(1);
                orderAppCardBean.ʽ(reserveDbInfo.ˏॱ());
                orderAppCardBean.ॱᐝ(reserveDbInfo.ᐝॱ());
                orderAppCardBean.ˏ(4);
                orderAppCardBean.ˎ(reserveDbInfo.ॱˋ());
                orderAppCardBean.ͺ(reserveDbInfo.ʾ());
                ˊ(i, list.size(), orderAppCardBean);
                arrayList.add(orderAppCardBean);
            }
        }
        return arrayList;
    }

    private void ˊ(int i, int i2, OrderAppCardBean orderAppCardBean) {
        if (i == i2 - 1) {
            orderAppCardBean.ʻ(true);
        }
    }

    private void ˏ(cia o_cia, List<CardBean> list, int i, long j) {
        if (o_cia == null) {
            Logger.e("PersonalReservedManager", "addCardArea error, cardDataProvider = null , recordCardId = " + j);
            return;
        }
        int i2 = 0;
        if (!(list == null || list.isEmpty())) {
            i2 = list.size();
        }
        o_cia.ˋ(j, i, i2, list);
    }
}
